﻿using System;

namespace Glossary
{
    public class Word
    {
        private string _foreign;
        private string _swedish;
        private string _answer;
        private bool _correct;

        public string Foreign
        {
            get { return _foreign; }
            set { _foreign = value; }
        }

        public string Swedish
        {
            get { return _swedish; }
            set { _swedish = value; }
        }

        public string Answer
        {
            get { return _answer; }
            set { _answer = value; }
        }

        public bool Correct
        {
            get { return _correct; }
            private set { _correct = value; }
        }

        private int _wordID;

        public int WordID
        {
            get { return _wordID; }
            set { _wordID = value; }
        }
        

        /// <summary>
        /// Empty constructor.
        /// </summary>
        public Word()
        {

        }

        /// <summary>
        /// This is the standard constructor for Word.
        /// </summary>
        /// <param name="foreign"></param>
        /// <param name="swedish"></param>
        public Word(string foreign, string swedish)
        {
            _foreign = foreign;
            _swedish = swedish;
        }

        public Word(string foreign, string swedish, int wordid)
        {
            _foreign = foreign;
            _swedish = swedish;
            _wordID = wordid;
        }

        /// <summary>
        /// This is another constructor for Word, with three in-parameters.
        /// </summary>
        /// <param name="foreign"></param>
        /// <param name="swedish"></param>
        /// <param name="answer"></param>
        public Word(string foreign, string swedish, string answer)
        {
            _foreign = foreign;
            _swedish = swedish;
            _answer = answer;
        }
        public Word(string foreign, string swedish, string answer, bool corrected)
        {
            _foreign = foreign;
            _swedish = swedish;
            _answer = answer;
            _correct = corrected;
        }

        /// <summary>
        /// This method checks if the property answer is the same as either the property Swedish or Foreign.
        /// </summary>
        /// <returns>Returns the Correct property.</returns>
        public bool CheckAnswer(CaseSensitive cs)
        {
            if (_answer == null || _answer == "")
            {
                _correct = false;
                return _correct;
            }
            switch (cs)
            {
                case CaseSensitive.CaseSensitive:
                    //_correct = (_answer == _foreign || _answer == _swedish);
                    _correct = (_answer == _swedish);
                    break;
                case CaseSensitive.NonCaseSensitive:
                    //_correct = (_answer.ToLower() == _foreign.ToLower() || _answer.ToLower() == _swedish.ToLower());
                    _correct = (_answer.ToLower() == _swedish.ToLower());
                    break;
            }

            return _correct;
        }

        public override string ToString()
        {
            return String.Format("{0};{1}", _foreign, _swedish);
        }

        //static public bool operator ==(Word one, Word two)
        //{
        //    try
        //    {
        //        return (one._foreign == two.Foreign && one._swedish == two._swedish);
        //    }
        //    catch (NullReferenceException)
        //    {
        //        return false;
        //    }
        //}

        //static public bool operator !=(Word one, Word two)
        //{
        //    try
        //    {
        //        return (one._foreign == two.Foreign && one._swedish == two._swedish) ? false : true;
        //    }
        //    catch (NullReferenceException)
        //    {
        //        return true;
        //    }
        //}

        //public override bool Equals(object obj)
        //{
        //    return base.Equals(obj);
        //}

        //public override int GetHashCode()
        //{
        //    return base.GetHashCode();
        //}

    }




}
